<template>
    <div id="animation">
      <button @click="toggle">显示隐藏</button>
      <!--<transition name="show">-->
        <!--<span v-show="isshow">{{ msg }}</span>-->
      <!--</transition>-->

      <transition @before-enter="beforeEnter" @enter="enter" @after-enter="afterEnter">
        <div v-show="isshow" class="show">hello vue.js</div>
      </transition>
    </div>
</template>

<script>
    export default {
        name: "animation",
      data(){
          return{
            isshow:false,
            msg:'hello vue.js'
          }
      },
      methods:{
          toggle:function () {
            this.isshow = !this.isshow;
          },
        beforeEnter:function (el) {
          el.style.transform = "translate(150px,0)";
        },
        enter:function (el,done) {
          el.offsetWidth;
          el.style.transform = "translate(0px,0)";
          done();
        },
        afterEnter:function () {
          this.ishow = !this.isshow;
        }
      }
    }
</script>

<style scoped>
  .show-enter-active,.show-leave-active{
    transition:all 0.4s ease;
    padding-left:10px;
  }
  .show-enter,.show-leave-active{
    padding-left:100px;
  }
  .show{
    transition:all 0.4s ease;
  }
</style>
